package com.xzl.xep.pojo;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;

@Entity
@Table(name="dp_sale")
public class Sale extends IdEntity {

	@NotNull
	private Integer isCustomer;
	
	private Long customerId;
	
	private String  customerName;
	


	private Payment payment;
	
	@NotNull
	private Long companyId;
	
	@NotBlank
	private String companyName;
	

	private Set<SaleDetail> details;
	
	@NotNull
	private Double saleMoney;
	
	@NotNull
	private Double payMoney;
	
	@NotNull
	private Double preferenMoney;
	
	
	@NotNull
	private Long operatorId;
	
	@NotBlank
	private String operatorName;

	public Integer getIsCustomer() {
		return isCustomer;
	}

	public void setIsCustomer(Integer isCustomer) {
		this.isCustomer = isCustomer;
	}

	public Long getCustomerId() {
		return customerId;
	}

	public void setCustomerId(Long customerId) {
		this.customerId = customerId;
	}

	public String getCustomerName() {
		return customerName;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	@OneToOne(cascade=CascadeType.ALL,fetch = FetchType.EAGER )  
    @JoinColumn(name="payment_id")  
	public Payment getPayment() {
		return payment;
	}

	public void setPayment(Payment payment) {
		this.payment = payment;
	}

	
 	@OneToMany(cascade=CascadeType.ALL,fetch = FetchType.LAZY, mappedBy = "sale") 
	public Set<SaleDetail> getDetails() {
		return details;
	}

	public void setDetails(Set<SaleDetail> details) {
		this.details = details;
	}

	public Double getSaleMoney() {
		return saleMoney;
	}

	public void setSaleMoney(Double saleMoney) {
		this.saleMoney = saleMoney;
	}

	public Double getPayMoney() {
		return payMoney;
	}

	public void setPayMoney(Double payMoney) {
		this.payMoney = payMoney;
	}

	public Double getPreferenMoney() {
		return preferenMoney;
	}

	public void setPreferenMoney(Double preferenMoney) {
		this.preferenMoney = preferenMoney;
		
	}

	public Long getOperatorId() {
		return operatorId;
	}

	public void setOperatorId(Long operatorId) {
		this.operatorId = operatorId;
	}

	public String getOperatorName() {
		return operatorName;
	}

	public void setOperatorName(String operatorName) {
		this.operatorName = operatorName;
	}

	public Long getCompanyId() {
		return companyId;
	}

	public void setCompanyId(Long companyId) {
		this.companyId = companyId;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	
	
	
}
